package ui.widget;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Toolkit;

import javax.swing.JLabel;

import ui.util.YPUIUtil;

//文字面板
public class TxtPanel extends TransparentPanel {
	private JLabel txt = new JLabel();

	public TxtPanel(String text) {
		init(text);
	}

	public TxtPanel(int w, int height, String text) {
		// this.setMinimumSize(new Dimension(w, height));
		this.setPreferredSize(new Dimension(w, height));
		this.setMaximumSize(new Dimension(w, height));
		init(text);
	}

	public TxtPanel(int height, String text) {
		this(YPUIUtil.getScreenWidth(),height,text);
	}

	private void init(String text) {
		setLayout(new BorderLayout());
		this.txt.setText(text);
		add(txt, BorderLayout.CENTER);
	}

	public TxtPanel setText(String text) {
		txt.setText(text);
		return this;
	}

	public String getText() {
		return txt.getText();
	}

	public TxtPanel setFontColor(Color c) {
		txt.setForeground(c);
		return this;
	}

	public Color getFontColor() {
		return txt.getForeground();
	}

	public TxtPanel mSetFont(Font font) {
		txt.setFont(font);
		return this;
	}
}
